###
 # @Descripttion: 
 # @version: 
 # @Author: 王政乔(https://www.zhengqiao.wang/)
 # @Date: 2020-05-08 10:42:38
 # @LastEditors: 王政乔(https://www.zhengqiao.wang/)
 # @LastEditTime: 2020-05-08 11:05:56
 ###

#!/bin/bash

# expr 运算，只支持整数
a=123
b=456
echo "expr方法"
echo "a=$a ,b=$b"

# 加
plus=`expr $a + $b`
echo "a + b = $plus"
# 减
minus=`expr $a - $b`
echo "a - b = $minus"
# 乘
time=`expr $a \* $b`
echo "a * b = $time"
# 除
divide=`expr $a / $b`
echo "a / b = $divide"
# 取余
mod=`expr $a % $b`
echo "a Mod b = $mod"

# bc 运算，支持浮点数
echo "bc方法"
c=66.66
d=2.2

# 加
plus=`echo "$c + $d" | bc`
echo "c + d = $plus"
# 减
minus=`echo "$c - $d" | bc`
echo "a - b = $minus"
# 乘
time=`echo "$c * $d" | bc`
echo "a * b = $time"
# 除
divide=`echo "$c / $d" | bc`
echo "a / b = $divide"
# 取余
mod=`echo "$c % $d" | bc`
echo "a Mod b = $mod"